package com.tianqu.tms.www.car.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.Car;
import com.tianqu.tms.www.car.controller.CarStockCountDetailController;
import com.tianqu.tms.www.car.viewhelper.CarStockCountListTopViewhelper;
/**
 * 库存统计下探页面Action
 * 
 * @author tianshifu
 *
 */
public class CarStockCountDetailAction extends TmsAction {

	private static final String MEMID = "memId";
	private static final String CARSCORE = "carScore";

	
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		
//		CarStockCountListTopViewhelper view = new CarStockCountListTopViewhelper();
//
//		//从前台获取一个车辆ID
//		String memId = "";
//		
//		if(request.getParameter(MEMID)!=null)
//		{
//			memId = request.getParameter(MEMID);
//		}else{
//			memId = (String)uc.getAttribute(MEMID);
//		}
//		
//		uc.removeAttribute(MEMID);
//		uc.setAttribute(MEMID, memId);
//		
//		CarStockCountDetailController controller = new CarStockCountDetailController();
//		controller.execute(uc);
//		
//		view = (CarStockCountListTopViewhelper)uc.getAttribute(TmsConstants.VIEWHELP);
//		
//		request.setAttribute(TmsConstants.VIEWHELP, view);
//		uc.removeAttribute(TmsConstants.VIEWHELP);
//		return mapping.findForward(TmsConstants.SUCCESS);
		
		CarStockCountListTopViewhelper view = new CarStockCountListTopViewhelper();

		//从前台获取一个车辆ID
		String memId = "";
		String carScore = "";
		
		if(request.getParameter(MEMID)!=null)
		{
			memId = request.getParameter(MEMID);
		}else{
			memId = (String)uc.getAttribute(MEMID);
		}
		
		if(request.getParameter(CARSCORE)!=null)
		{
			carScore = request.getParameter(CARSCORE);
		}else{
			carScore = (String)uc.getAttribute(CARSCORE);
		}
		
		uc.removeAttribute(MEMID);
		uc.setAttribute(MEMID, memId);
		
		uc.removeAttribute(CARSCORE);
		uc.setAttribute(CARSCORE, carScore);
		
		CarStockCountDetailController controller = new CarStockCountDetailController();
//		controller.execute(uc);
		controller.detail(uc);
		view = (CarStockCountListTopViewhelper)uc.getAttribute(TmsConstants.VIEWHELP);
		
		request.setAttribute(TmsConstants.VIEWHELP, view);
		uc.removeAttribute(TmsConstants.VIEWHELP);
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
